<!-- 项目资料 -->
<template>
  <div class="card">
    <div class="card-header">
      <div class="common-sub-title">项目资料</div>
      <el-button plain @click="handleSave">保存</el-button>
    </div>
    <el-form
      ref="ruleFormRef"
      :model="ruleForm"
      :rules="rules"
      hide-required-asterisk>
      <el-form-item label="项目合同" prop="projectContractUrl">
        <Upload text="合同上传" />
      </el-form-item>
      <el-form-item label="招标文件" prop="bidDocumentUrl">
        <Upload text="文件上传" />
      </el-form-item>
      <el-form-item label="中标通知书" prop="letterUrl">
        <Upload text="通知书上传" />
      </el-form-item>
    </el-form>
  </div>
</template>

<script setup>
import Upload from './upload.vue'
const ruleForm = reactive({
  // 项目合同
  projectContractUrl: '',
  // 招标文件
  bidDocumentUrl: '',
  // 中标通知书
  letterUrl: '',
})

const rules = reactive({
  projectContractUrl: [{ required: true, message: '请上传项目合同' }],
  bidDocumentUrl: [{ required: true, message: '请上传招标文件' }],
  letterUrl: [{ required: true, message: '请上传中标通知书' }],
})

// 表单校验
const ruleFormRef = ref(null)
function validateForm() {
  return new Promise((resolve, reject) => {
    ruleFormRef.value.validate(valid => {
      if (valid) {
        resolve(ruleForm)
      }
    })
  })
}

// 保存
function handleSave(){
  validateForm()
  .then(res=>{
    console.log(res,'保存')
  })
}

defineExpose({
  validateForm
})
</script>

<style lang="scss" scoped>
</style>
